package com.junjiao.util.dao.paging;

/**
 * 分页查询条件
 * 
 * @project jiaojun_util
 * @ClassName SearchBean.java
 * @author jiaojun
 * @email junjiao.j@gmail.com
 * @version v0.0.1
 * @date 2012-4-28
 */
public class SearchBean {
	/**
	 * 每页记录数
	 */
	private int rowsPerPage;
	/**
	 * 当前页数
	 */
	private int currentPage;
	/**
	 * 起始数
	 */
	private int start;
	/**
	 * 结束数
	 */
	private int end;
	/**
	 * 总记录数
	 */
	private int totalRecords;
	/**
	 * 总页数
	 */
	private int totalPages;

	public SearchBean() {
		rowsPerPage = 25;
		currentPage = 1;
		totalRecords = -1;
	}

	public int getRowsPerPage() {
		return rowsPerPage;
	}

	public void setRowsPerPage(int rowsPerPage) {
		this.rowsPerPage = rowsPerPage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getEnd() {
		if (totalRecords < rowsPerPage) {
			end = totalRecords;
		} else if ((totalRecords % rowsPerPage == 0)
				|| (totalRecords % rowsPerPage != 0 && currentPage < totalPages)) {
			end = currentPage * rowsPerPage;
		} else if (totalRecords % rowsPerPage != 0 && currentPage == totalPages) {// 最后一页
			end = totalRecords;
		}
		return end;
	}

	public int getStart() {
		start = (currentPage - 1) * rowsPerPage;
		return start;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
}
